import React, {Component} from 'react';
import {r} from "./Const"

class Vertex extends Component {

    constructor() {
        super();
    }

    dye = () => {
        if (!this.props.current)
            return 'white';
        switch (this.props.type) {
            case 1:
            case 4:
                return this.props.visited ? 'lightyellow' :'lightgreen';
            case 2:
            case 3:
                return this.props.color;
        }
    }

    render() {
        let tspan;
        tspan = <tspan x={this.props.pos.x} dy='1.6em' >{this.props.label}</tspan>
        return (
            <g>
                <circle
                    cx={this.props.pos.x}
                    cy={this.props.pos.y}
                    r={r}
                    stroke="black" strokeWidth="0.5" fill={
                        this.dye()}
                >
                </circle>
                <text
                    style={{font:'3px sans-serif'}}
                    x={this.props.pos.x}
                    y={this.props.pos.y-4}
                    textAnchor={'middle'}
                    // alignmentBaseline={'top'}
                >
                    {tspan}
                </text>

            </g>
        );
    }
}


export default Vertex;